﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Chefbook.HelperMethods
{
    public static class CollectionExtensionMethods
    {
        /// <summary>
        /// Adds an item to a collection if the collection does not already contain that item
        /// </summary>
        /// <typeparam name="T">The Type of the item to add</typeparam>
        /// <param name="collection">The collection to add to</param>
        /// <param name="itemToAdd">The item to add</param>
        public static void AddIfNew<T>(this ICollection<T> collection, T itemToAdd)
        {
            if (!collection.Contains(itemToAdd))
                collection.Add(itemToAdd);
        }
    }
}
